package com.fast.develop.meta.dm;


import com.fast.develop.meta.dm.builder.MetaFieldBuilder;
import com.fast.develop.meta.dm.field.FieldCatelog;
import com.fast.develop.meta.dm.value.ValueGeneration;
import com.fast.develop.meta.dm.value.ValueValidation;

import java.util.List;

/**
 * @author 莫寅
 * @createTime 2022-06-01 15:19
 * @desc：
 */
public class MetaField {

    private FieldCatelog type;

    private String name;
    /**表字段**/
    private String columnName;

    private String comment;

    //默认值
    private ValueGeneration valueGenerationStrategy;

    //检验
    private List<ValueValidation> valueValidations;

    /**长度**/
    private Integer length = 0;
    /**小数位数**/
    private Integer decimalLength = 0;
    /**是否必输**/
    private Boolean required;
    /**是否主键**/
    private Boolean primaryKey;
    /**是否唯一**/
    private Boolean unique;

    /**是否可导入导出**/
    private Boolean canExcel = true;

    /**接口是否可见, 模板 apiHide **/
    private Boolean apiHide = false;

    public MetaField(MetaFieldBuilder metaFieldBuilder) {
        this.type = metaFieldBuilder.getType();
        this.name = metaFieldBuilder.getName();
        this.columnName = metaFieldBuilder.getColumnName();
        this.comment = metaFieldBuilder.getComment();
        this.valueGenerationStrategy = metaFieldBuilder.getValueGenerationStrategy();
        this.valueValidations = metaFieldBuilder.getValueValidations();
        this.length = metaFieldBuilder.getLength();
        this.decimalLength = metaFieldBuilder.getDecimalLength();
        this.required = metaFieldBuilder.getRequired();
        this.primaryKey = metaFieldBuilder.getPrimaryKey();
        this.canExcel = metaFieldBuilder.getCanExcel();
        this.apiHide = metaFieldBuilder.getApiHide();
        this.unique = metaFieldBuilder.getUnique();
    }

    public FieldCatelog getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public String getColumnName() {
        return columnName;
    }

    public String getComment() {
        return comment;
    }

    public ValueGeneration getValueGenerationStrategy() {
        return valueGenerationStrategy;
    }

    public List<ValueValidation> getValueValidations() {
        return valueValidations;
    }

    public Integer getLength() {
        return length;
    }

    public Integer getDecimalLength() {
        return decimalLength;
    }

    public Boolean getRequired() {
        return required;
    }

    public Boolean getPrimaryKey() {
        return primaryKey;
    }

    public Boolean getCanExcel() {
        return canExcel;
    }

    public Boolean getApiHide() {
        return apiHide;
    }

    public Boolean getUnique() {
        return unique;
    }
}
